package com.base.cn.platform.os.entity.course.cloud;


import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalTime;
import java.util.Date;

@Data
@EqualsAndHashCode(callSuper = false)
public class DemandEntity {
    // 录播名
    private String name;
    // 添加时间(单位是s)
    private long add_time;
    // 状态
    private String status;
    // 播放码
    private String id_varchar;
    // 时长
    private int video_duration;
    // 文件类型
    private int file_type;

    // 添加时间
    private Date createTime;

    // 时长
    private String duration;

    public void setCreateTime() {
        this.createTime = new Date(this.add_time * 1000);
    }

    public void setStatus() {
        String status = "不合法状态";
        switch (this.status) {
            case "init":
                status = "待转码";
                break;
            case "progress":
                status = "转码中";
                break;
            case "finish":
                status = "转码成功";
                break;
            case "error":
                status = "转码失败";
                break;
            case "delete":
                status = "已删除";
                break;
            default:
                break;
        }
        this.status = status;
    }

    public void setDuration() {
        LocalTime time = LocalTime.ofSecondOfDay(video_duration);
        if (this.video_duration < 60) {
            this.duration = "0:" + time.getSecond();
        } else if (this.video_duration < 3600) {
            this.duration = time.getMinute() + ":" + time.getSecond();
        } else {
            this.duration = time.getHour() + ":" + time.getMinute() + ":" + time.getSecond();
        }
    }
}
